package com.xframe.xdal.core.model.mapping;

import com.xframe.xdal.core.annotation.XHasMany;
import lombok.Data;

/**
 * 定义了一个引用子表的关系
 *
 * @author xufeng
 * @version 1.0
 * @date 2022-09-19
 */
@Data
public class HasManyMapping extends BaseRelation {



    public static HasManyMapping valueOf(XHasMany xHasMany){
        HasManyMapping hasManyMapping = new HasManyMapping();
        hasManyMapping.foreignKey = xHasMany.foreignKey();
        hasManyMapping.targetKey = xHasMany.targetKey();
        hasManyMapping.refTableAddString = xHasMany.refTableAddString();
        hasManyMapping.as = xHasMany.as();
        hasManyMapping.typeName = xHasMany.typeName();
        hasManyMapping.refName = xHasMany.refName();
        return hasManyMapping;
    }

    public static HasManyMapping valueOf(String foreignKey,String targetKey,String as,String typeName,String refTableAddString){
        HasManyMapping hasManyMapping = new HasManyMapping();
        hasManyMapping.foreignKey = foreignKey;
        hasManyMapping.targetKey = targetKey;
        hasManyMapping.refTableAddString = refTableAddString;
        hasManyMapping.as = as;
        hasManyMapping.typeName = typeName;
        hasManyMapping.refName = "";
        return hasManyMapping;
    }

    public static HasManyMapping valueOf(String foreignKey,String targetKey,String as,String typeName,String refName,String refTableAddString){
        HasManyMapping hasManyMapping = new HasManyMapping();
        hasManyMapping.foreignKey = foreignKey;
        hasManyMapping.targetKey = targetKey;
        hasManyMapping.refTableAddString = refTableAddString;
        hasManyMapping.as = as;
        hasManyMapping.typeName = typeName;
        hasManyMapping.refName = refName;
        return hasManyMapping;
    }
}
